<?php
/**
 * Email rule
 * Validates that value is a valid e-mail address. Validates that the e-mail
 * address is well-formed and then checks that the domain is real.
 * 
 * @package     Q-Validate
 * @subpackage  Rules
 * @author      Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright   (c) 2010 Luke Visinoni <luke.visinoni@gmail.com>
 * @version     $Id: Email.php 47 2011-05-29 20:15:36Z luke.visinoni $
 */
class Q_Rule_Email extends Q_Rule_Abstract {

    protected $_params = array(
        'validateMX' => true,
    );
    
    public function isValid($value) {
    
        if(filter_var($value, FILTER_VALIDATE_EMAIL)) {
            list($name, $domain) = explode('@', $value);
            if ($this->getParam('validateMX')) {
                return getmxrr($domain, $hosts);
            }
            return true;
        }
        return false;
    
    }

}
